package com.cq.hd.order.controller;

import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.order.api.TbOrderSettleBillApi;
import com.cq.hd.order.api.dto.OrderSettleBillDto;
import com.cq.hd.order.api.dto.OrderSettleBillUpdateStateDto;
import com.cq.hd.order.api.vo.MerchantOrderAmtStatVo;
import com.cq.hd.order.api.vo.OrderSettleBillVo;
import com.cq.hd.order.service.HfTransferRetryService;
import com.cq.hd.order.service.TbOrderSettleBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 订单结算支付流水记录表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2024-01-23
 */
@RestController
public class TbOrderSettleBillController implements TbOrderSettleBillApi {

    @Autowired
    private TbOrderSettleBillService orderSettleBillService;
    @Autowired
    private HfTransferRetryService hfTransferRetryService;

    @Override
    public Result<List<OrderSettleBillVo>> listByDto(OrderSettleBillDto orderSettleBillDto) {
        return ResultGenerator.success(orderSettleBillService.listByDto(orderSettleBillDto));
    }

    @Override
    public Result<Boolean> transactAmt(@RequestBody OrderSettleBillVo orderSettleBillVo) {
        return ResultGenerator.success(orderSettleBillService.transactAmt(orderSettleBillVo));
    }

    @Override
    public Result<Boolean> transferByOrderSettleBill(OrderSettleBillVo orderSettleBillVo) {
        return ResultGenerator.success(orderSettleBillService.transferByOrderSettleBill(orderSettleBillVo));
    }

    @Override
    public Result<OrderSettleBillVo> getById(Long id) {
        return ResultGenerator.success(orderSettleBillService.getOrderSettleBillById(id));
    }

    @Override
    public Result<MerchantOrderAmtStatVo> getMerchantPendingAmt(Long merchantId) {
        return ResultGenerator.success(orderSettleBillService.getMerchantPendingAmt(merchantId));
    }

    @Override
    public Result<BigDecimal> getBusinessWaitPaySubsidyAmt(Long businessId) {
        return ResultGenerator.success(orderSettleBillService.getBusinessWaitPaySubsidyAmt(businessId));
    }

    @Override
    public Result<Integer> updateTradeState(OrderSettleBillUpdateStateDto orderSettleBillUpdateStateDto) {
        return ResultGenerator.success(orderSettleBillService.updateTradeState(orderSettleBillUpdateStateDto));
    }

    @Override
    public Result<Void> merchantAmtTransferRetry() {
        hfTransferRetryService.merchantAmtTransferRetry();
        return ResultGenerator.success();
    }

    @Override
    public Result<Void> scanRecoverAmtTransfer() {
        orderSettleBillService.scanRecoverAmtTransfer();
        return ResultGenerator.success();
    }
}
